package com.h3c.nem.service;

import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
import com.baomidou.mybatisplus.extension.service.IService;
import com.h3c.nem.dto.OptionsDTO;
import com.h3c.nem.dto.SdDeptDTO;
import com.h3c.nem.entity.SdDept;
import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * Copyright (C), 2020-2020, h3c
 * FileName: ISdDeptService
 *
 * @Author: l22886
 * @Date: 2022-01-19
 * Description: sd_dept service
 * Version: 1.0
 */
public interface ISdDeptService extends IService<SdDept> {

    /**
     * @title: selectFuzzyByDto
     * @description: 模糊查询操作
     * @params: [ dto ]
     * @return: java.util.List
     * @createTime: 2022-01-19
     * @version: 1.0
     * @author: l22886
     */
    public List<SdDeptDTO> selectFuzzyByDto(SdDeptDTO dto);

    /**
     * @title: selectByDto
     * @description: 精确查询操作
     * @params: [ dto ]
     * @return: java.util.List
     * @createTime: 2022-01-19
     * @version: 1.0
     * @author: l22886
     */
    public List<SdDeptDTO> selectByDto(SdDeptDTO dto);

    /**
     * @title: insertDto
     * @description: 插入操作
     * @params: [ dto ]
     * @return: Integer
     * @createTime: 2022-01-19
     * @version: 1.0
     * @author: l22886
     */
    public Integer insertDto(SdDeptDTO dto);

    /**
     * @title: updateDto
     * @description: 修改操作
     * @params: [ dto ]
     * @return: Integer
     * @createTime: 2022-01-19
     * @version: 1.0
     * @author: l22886
     */
    public Integer updateDto(SdDeptDTO dto);

    /**
     * @title: deleteDto
     * @description: 删除操作
     * @params: [ dto ]
     * @return: Integer
     * @createTime: 2022-01-19
     * @version: 1.0
     * @author: l22886
     */
    public Integer deleteDto(SdDeptDTO dto);

    public void synceSdDept(Boolean timeFlag);

    /**
     * 部门人员维护邮件
     */
    public void sendEmailForDept();

    public File download(SdDeptDTO paramsDTO, String templateCode, String fileName);

    Integer importDeptSetList(MultipartFile file);

    /**
     * 查询树形下拉菜单
     * @return
     */
    List<OptionsDTO> queryDeptTreeSelection(String deptIds);

    /**
     * 查询所有子部门
     * @return
     */
    List<SdDeptDTO> qyeryChidrenDeptList(SdDeptDTO sdDeptDTO);

    /**
     * 设置部门相关人员
     * @return
     */
    Integer setDeptUserRole(SdDeptDTO sdDeptDTO);

    /**
     * 查询子孙部门id
     * @param deptParentIds
     * @return 所有子孙部门id+父级id
     */
    Set<Integer> getDeptChildIds(String deptParentIds);

    Set<Integer> getAuthDeptIds(boolean bpAuth,boolean conAuth,boolean manAuth,boolean gbbzAuth);

    public void syncDeptManager();
    public void modify();

    /**
     * bp管理的部门
     * @return
     */
    List<String> getBpManageDeptNameChainList(SFunction<SdDept, String> sFunction);

    /**
     * 通过部门名称获取部门
     * @return
     */
    SdDept getDeptByNameChain(String nameChain);

    SdDept getDeptByNameChainNoException(String nameChain);

    /**
     * 城市接口人
     * @param deptNameChain
     * @param workCity
     * @return
     */
    String getContactorByDeptNameChain(String deptNameChain, String workCity);

    /**
     * 通过部门chain获取入职期BP
     * @param deptNameChain
     * @param offerBpList   role为14的BP
     * @param bpList role为15的BP
     * @return
     */
    String getBpByDeptNameChain(String deptNameChain, List<String> offerBpList, List<String> bpList);

    /**
     * 通过部门chain获取入职期BP
     * @param deptNameChain
     * @return
     */
    String getBpByDeptNameChain(String deptNameChain);

    /**
     * 获取id的id，name，email
     * @param workerIds
     * @return
     */
    Map<String, String> getWorkerMap(String workerIds);

    /**
     * 获取workerId对应的邮箱
     * @param workerIds
     * @return
     */
    List<String> getEmailList(String workerIds);

    /**
     * 查询bp和部门接口人的id，name，email
     * @param deptNameChain
     * @return
     */
    Map<String, String> getBpAndContactorByDeptNameChain(String deptNameChain, String workCity);

    String getSscDeptManagerId(String deptNameChain);

    /**
     * 获取bp 接口人 ssc
     * @param deptNameChain
     * @param workCity
     * @return
     */
    Map<String, String> getBpAndContactorAndSSC(String deptNameChain, String workCity);
}
